define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'xilujob/inform/index' + location.search,
                    edit_url: 'xilujob/inform/edit',
                    del_url: 'xilujob/inform/del',
                    multi_url: 'xilujob/inform/multi',
                    table: 'xilujob_inform',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false,},
                        {field: 'user.nickname', title: __('User_id')},
                        {field: 'job.job_name', title: __('Job_id'), formatter: Table.api.formatter.search},
                        {field: 'job_inform_type_id', searchList: $.get('xilujob.inform/search_list',{tbl:'xilujob_inform_type'}), title: __('Job_inform_type_id'), formatter: function(val,row){
                            console.log(row)
                            return row.inform_type.name}
                            },
                        {field: 'content', title: __('Content'), formatter:function(val, row){return val.replace(/\n/g,'<br>')},operate:false},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},
                        {field: 'contact', title: __('Contact'),operate:false},
                        {field: 'deal_status', title: __('处理状态'),searchList: {'0':"未处理",'1':"已处理"},formatter:Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});